package assist.datastore.parser;

import java.io.Reader;

import com.google.gson.Gson;
import assist.domain.model.Game;

public class NHLRosterJSONParser
{
    public NHLRosterJSONParser(final Game game, final Reader reader) throws Exception
    {
        //NOTE: The actual Roster URL is jsonp instead of regualr JSON.
        //SO the function name needs to be stripped.

        Gson gson = new Gson();
        
        JsonNhlRoster jsonRoster = gson.fromJson(reader, JsonNhlRoster.class);
        for(JsonNhlRoster.Player player : jsonRoster.data.home.skaters.player)
        {
            //TODO: Add the players to game
            //TODO: Move roster tests from the old one to thies one.
            
            System.out.println(player.num + ". " +  player.fname + " " +  player.lname
                     +" (" + player.pos +") " + player.playerId);
        }
    }
}
class JsonNhlRoster
{
    Data data;
    static class Data
    {
        Roster home;
        Roster away;
    }
    static class Roster
    {
        Players skaters;
        Players goalies;
    }
    static class Players
    {
        Player [] player;
    }
    static class Player
    {
        String lname;
        String fname;
        Integer num;
        String pos;
        Long playerId;        
    }
}
